/*
 * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef SLE_ANNOUNCE_H
#define SLE_ANNOUNCE_H

#include <iostream>
#include <memory>
#include "sle_announce_config.h"
#include "sle_common_config.h"
#include "sle_error_code.h"

namespace OHOS {
namespace NearLink {
namespace SleStandard {
class SleAnnounceCallback {
public:
    /**
     *   @brief A destructor used to delete the <b>SleAnnounceCallback</b> instance.
     */
    virtual ~SleAnnounceCallback() = default;

    /**
     *   @brief   Announce state change callback
     *
     *   @param   [in] announceId - announce id
     *   @param   [in] state - announce state
     *   @param   [in] terminal - whether the host is connected while announcing
     *   @return  None
     */
    virtual void OnAnnounceStateChange(uint8_t announceId, SleAnnounceState announceState, bool terminal) = 0;
};

// todo 定义类做参数校验及日志记录, 实现类impl做具体实现, 成员函数命名保持一致
class SleAnnounce {
public:
    /**
     *   @brief A constructor used to create a <b>SleAnnounce</b> instance.
     */
    SleAnnounce();

    /**
     *   @brief A constructor used to delete a <b>SleAnnounce</b> instance.
     */
    ~SleAnnounce();

    /**
     *  @brief  create announce id sync
     *
     *  @param  [out] announceId - announceId will less than SLE_MAX_ANNOUNCE_ID_NUM
     *  @return SleErrorCode
     */
    SleErrorCode AddAnnounce(uint8_t &announceId);

    /**
     *  @brief  remove announce id sync
     *
     *  @param  [in] announceId - announce id
     *  @return SleErrorCode
     */
    SleErrorCode RemoveAnnounce(uint8_t announceId);

    /**
     *   @brief   Start announce sync
     *
     *   @param   [in] announceId - announce id
     *   @param   [in] data - announce data
     *   @param   [in] setting - announce setting
     *   @return  SleErrorCode
     */
    SleErrorCode StartAnnounce(uint8_t announceId, SleAnnounceData &data, const SleAnnounceParam &setting);

    /**
     *   @brief   Start announce sync
     *
     *   @param   [in] announceId - announce id
     *   @return  SleErrorCode
     */
    SleErrorCode StopAnnounce(uint8_t announceId);

    /**
     *  @brief  get deault announce param sync
     *
     *  @param  [out] announceConfig - announce param config
     *  @return SleErrorCode - operation result
     */
    SleErrorCode GetDefaultAnnounceParamConfig(SleAnnounceParam &announceConfig);

    /**
     *   @brief   Register announce callback sync
     *
     *   @param   [in] callback - announce callback
     *   @return  SleErrorCode
     */
    SleErrorCode RegisterAnnounceCallback(std::shared_ptr<SleAnnounceCallback> callback);

    /**
     *   @brief   Unregister announce callback sync
     *
     *   @param   [in] callback - announce callback
     *   @return  SleErrorCode
     */
    SleErrorCode UnregisterAnnounceCallback(std::shared_ptr<SleAnnounceCallback> callback);

private:
    class SleAnnounceImpl;
    std::unique_ptr<SleAnnounceImpl> pimpl_;
    SLE_DISALLOW_COPY_AND_ASSIGN(SleAnnounce);
};
} // SleStandard
} // NearLink
} // OHOS

#endif // SLE_ANNOUNCE_H